<template>
  <div></div>
</template>
<script setup lang="ts">
import emitter from '../utils/emitter';
// 实现任意主键的通信
emitter.on('test1', () => {
  console.log('test1 被调用了')
})
emitter.on('test2', () => {
  console.log('test2 被调用了')
})

setInterval(() => {
  emitter.emit('test1')
  emitter.emit('test2')
}, 1000)

setTimeout(() => {
  emitter.off('test1')
}, 3000)

setTimeout(() => {
  emitter.all.clear()
}, 4000)
</script>

<style lang="scss" scoped></style>
